/**
 * @author LKQ
 * @date 2022/1/14 11:06
 * @description 模拟加法
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.addStrings("1", "9");
    }
    public String addStrings(String num1, String num2) {
        StringBuffer sb = new StringBuffer();
        int m = num1.length(), n = num2.length();
        int p = 0, q = 0, add = 0;
        while (p < m || q < n || add != 0) {
            int number1 = p >= m ? 0 : num1.charAt(m - p - 1) - '0';
            int number2 = q >= n ? 0 : num2.charAt(n - q - 1) - '0';
            int result = number1 + number2 + add;
            sb.append(result % 10);
            add = result / 10 ;
            p++;
            q++;
        }
        return sb.reverse().toString();
    }
}
